<?php
include_once "../header1.php";
?>

</head>
<body>
<?php
include_once ("$basedir"."/Login/databaseconnection.php");

if(!loggedin())
{
	require_once ("$basedir"."/index.php");
}
else
{	
if(isset($_POST['Search']))
{
if($School_Id=="Select One")
{
	$_SESSION['error']="Not enough inputs!";
}
}

?>
 <?php

include_once "../header2.php";


?>
<?php
include_once "topmenu.php";
?>
<div class="left">
  
<div class="articles">
<form method="POST">
  <table width="792" height="113" border="0">
      <tr>
        <td height="33" colspan="4" align="left" scope="row">
		<?php
		if(isset($_POST['Search']))
{
	if(isset($_SESSION['error']))
	{
		echo $_SESSION['error'];
		unset($_SESSION['error']);
	}
	if(isset($_SESSION['errornor']))
	{
		echo $_SESSION['errornor'];
		unset($_SESSION['errornor']);
	}
}
		?>
        </td>
        <td width="71" rowspan="3">Other Way:</td>
        <td width="246" rowspan="3"><table width="225" border="1">
          <tr>
            <td width="215"><input type="text" name="textfield3" />
              
              <input name="SearchOther" align="middle" type="submit" value="Search" />
              </td>
            </tr>
        </table></td>
      </tr>
      <tr>
        <td width="111" rowspan="2" align="left" scope="row">Search by</td>
      <td width="167" height="22" align="left" scope="row">School Id:</td>
      <td width="36" align="left" scope="row">:-</td>
      <td width="135"><select name="School_Id" id="select">
       <?php
	  
	  if(isset($_POST['Search']))
	  {
	 echo '<option value="'.$School_Id.'">'.$School_Id.'</option>';
	  }
	  else
	  {
	  echo '<option value="Select One">Select One</option>';
	  
	  ?>
        <?php
	 $tea=mysql_query("SELECT DISTINCT(School_Id) FROM teacher");
	  
  while($row=mysql_fetch_array($tea))
  {
	 $Sch_Id=$row['School_Id'];

	  echo '<option value="'.$Sch_Id.'">'.$Sch_Id.'</option>';
  }
  }
	  ?>
      </select></td>
      </tr>
    <tr>
     
    </tr>
    <tr>
      <th height="34" colspan="2" align="left" scope="row"><p><a href="searchtea.php">Reset</a>|
       <input name="Search" align="middle" type="submit" value="Search" /> </th>
  </table>
  </form>
  <?php
  
if(isset($_POST['Search']))
{
	
	 $School_Id=$_POST['School_Id'];
	 

if($School_Id!="Select One")
{
	if(mysql_num_rows("SELECT * FROM teacher WHERE School_Id='$School_Id'" )==0)
	{
		$_SESSION['errornor']="Sorry there is no teacher's record for this school!";
	}
	else
	{

$result=mysql_query("SELECT * FROM teacher WHERE School_Id='$School_Id'" );

 echo '<div style =" width:980px; height:377px; overflow-x:scroll; ">'; 
 echo '<table  border="1">';
 echo '	<tr align="center">';
echo '<th width="94">';
echo "Nic_Number";
echo '</th>';
echo '<th width="94">';
echo "School_Id";
echo '</th>';
echo '<th width="94">';
echo "First_Name";
echo '</th>';
echo '<th width="130">';
echo "Last_Name";
echo '</th>';
echo '<th width="158">';
echo 'Date_of_Birth';
echo '</th>';
echo '<th width="158">';
echo 'Gender';
echo '</th>';
echo '<th width="137">';
echo 'Nature_of_Appointment';
echo '</th>';
echo '<th width="93">';
echo 'Service';
echo '</th>';
echo '<th width="159">';
echo 'Acadamic_Qualifications';
echo '</th>';
echo '<th width="159">';
echo 'Professional_Qualifications';
echo '</th>';
echo '<th width="159">';
echo 'Achievements';
echo '</th>';
echo '<th width="159">';
echo 'Address';
echo '</th>';
echo '<th width="159">';
echo 'Mobile_Telephone_Number';
echo '</th>';
echo '<th width="159">';
echo 'Home_Telephone_Number';
echo '</th>';
echo '<th width="159">';
echo 'Office_Telephone_Number';
echo '</th>';
echo '<th width="159">';
echo 'Appointment_Date';
echo '</th>';
echo '<th width="159">';
echo 'Appointed_Subject';
echo '</th>';
echo '</tr>';
  while($row=mysql_fetch_array($result))
 {
	 echo '<tr align="center">';
  echo '<td>'.$row['T_NIC_Number'].'</td>';
  echo '<td>'.$row['School_Id'].'</td>';
  echo '<td>'.$row['First_Name'].'</td>';
 echo '<td>'.$row['Last_Name'].'</td>';
  echo '<td>'.$row['Date_Of_Birth'].'</td>';
  echo '<td>'.$row['Gender'].'</td>';
  echo '<td>'.$row['Nature_Of_Appointment'].'</td>';
  echo '<td>'.$row['Service'].'</td>';
  echo '<td>'.$row['Acadamic_Qualifications'].'</td>';
  echo '<td>'.$row['Professional_Qualifications'].'</td>';
  echo '<td>'.$row['Achievements&Awards'].'</td>';
  echo '<td>'.$row['Address'].'</td>';
  echo '<td>'.$row['Mobile_Tp_Number'].'</td>';
  echo '<td>'.$row['Home_Tp_Number'].'</td>';
  echo '<td>'.$row['Office_Tp_Number'].'</td>';
  echo '<td>'.$row['Appointment_Date'].'</td>';
  echo '<td>'.$row['Appointed_Subject'].'</td>';
  echo '</tr>';
  
  }
  
  echo "</table>";
  echo "</div>";
	}
  
  }
  
	} 
	?>
       <?php
}
?>
   
</div>

</div>


<div class="rightmenu"> 
<?php
include_once "menu.php";
?>
<?php
include_once "../footer.php";
?>
</body>
</html>